package com.liehacker.android.mapservice;

import java.util.List;

import com.liehacker.android.R;

import android.app.Activity;
import android.content.Context;
import android.location.Criteria;
import android.location.LocationManager;
import android.os.*;
import android.widget.TextView;

public class C24_GetProvider extends Activity {

	TextView tvText;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.c24_getprovicer);

		tvText = (TextView) findViewById(R.id.tv_c24_provider);

		// 위치 관리자 구하자.
		LocationManager LocMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

		// 제공자 목록을 구하자.
		List<String> arProvider = LocMan.getProviders(false);
		String strResult = "";
		for (int n = 0; n < arProvider.size(); n++) {
			strResult += ("Provider " + n + " : " + arProvider.get(n) + "\n");
		}

		// 최적의 제공자 조사.
		Criteria	crit = new Criteria();
		crit.setAccuracy(Criteria.NO_REQUIREMENT);
		crit.setPowerRequirement(Criteria.NO_REQUIREMENT);
		crit.setAltitudeRequired(false);
		crit.setCostAllowed(false);
		String best = LocMan.getBestProvider(crit, true);
		strResult += ("\nbest provider : " + best + "\n\n");
		
		// GPS와 네트워크 제공자 사용 가능성 조사
		strResult += LocationManager.GPS_PROVIDER + " : " + 
			LocMan.isProviderEnabled(LocationManager.GPS_PROVIDER) + "\n";
		strResult += LocationManager.NETWORK_PROVIDER  + " : " + 
			LocMan.isProviderEnabled(LocationManager.NETWORK_PROVIDER ) + "\n";
		
		
		tvText.setText(strResult);
	}
}
